<style>
    body {
        background: #f5f5f5;
    }
</style>
<div class="sectionY">
    <a href="javascript:history.back()">
        <img src="__PUBLIC__/home/images/a4.png" class="a1" alt="">
    </a>
    <p class="p1">共享矿机</p>
</div>
<div class="kong1"></div>
<div class="gong_section1 clearfix">
    <ul>
        <li class="select" onclick="javascript:location.href='{:url("Index/ourshop")}';">
            <a href="javascript:;">矿机列表</a>
            <span class="s1"></span>
        </li>
        <li onclick="javascript:location.href='{:url("Index/myshop")}';">
            <a href="javascript:;">我的矿机</a>
            <span class="s1"></span>
        </li>
        <li onclick="javascript:location.href='{:url("Index/endshop")}';" >
            <a href="javascript:;">过期矿机</a>
            <span class="s1"></span>
        </li>
    </ul>
</div>
<div class="gong_section2">
    {foreach $list as $item}
    <div class="list clearfix">
        <div class="left">
            <img src="{$item.img_url}" alt="">
        </div>
        <div class="center">
            <p class="p1">{$item.title}</p>
            <p class="p2">矿机价格：{$item.price} SCB</p>
            <p class="p2">运行周期：{$item.daynum}天</p>
            <p class="p2">每日收益：{$item.dayearn} SCB</p>
            <p class="p2">总收益：<?php echo ($item['daynum']*$item['dayearn']); ?> SCB</p>
        </div>
        <div class="last">
            <a href="javascript:;" onclick="buyshop('{$item.id}')">兑换</a>
        </div>
    </div>
    {/foreach}
</div>

<script>
    /*开始*/
    function buyshop(id){
        if(id=='' || id==undefined){
            layer.alert('系统参数错误，请刷新后再试！',{shade:0.2});return false;
        }

        $.ajax({
            type: 'POST',
            url: "{:url('Shop/getshop')}",
            dataType: "json",
            data: "id="+id,
            success:function(responsestr){
                var getcode = responsestr.result_code;
                var getinfo = responsestr.result_info;
                if(getcode==0){
                    layer.msg('兑换成功！',{icon:1,time:3000,shade:0.4},function() {
                        location.href = "{:url('Index/myshop')}";
                    });
                }else{
                    layer.msg(getinfo,{icon:2,time:2000,shade:0.4},function() {
                        location.href = "{:url('Index/ourshop')}";
                    });
                }
            },
            error:function(){
                r2('当前访客较多，请稍后再试！','1.png');
            }
        });
    }
</script>